package org.zhxy.zhxy.controller.backend;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.zhxy.zhxy.entity.dto.AdminForgetDto;
import org.zhxy.zhxy.entity.dto.AdminLoginDto;
import org.zhxy.zhxy.service.LoginService;
import org.zhxy.zhxy.utils.Result;


/**
 * 后台管理登录controller
 * @author pxx
 */
@RestController
@RequestMapping("/api/admin/login")
public class AdminLoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 账号密码登录
     */
    @PostMapping("/byPwd")
    public Result byPwd(@RequestBody AdminLoginDto adminLoginDto){
        return loginService.byPwd(adminLoginDto);
    }

    /**
     * 忘记密码
     */
    @PostMapping("/forgetPwd")
    public Result forgetPwd(@RequestBody AdminForgetDto adminForgetDto){
        return loginService.forgetPwd(adminForgetDto);
    }

    /**
     * 发送验证码
     */
    @GetMapping("/sendCode")
    public Result sendCode(@RequestParam("email") String email){
        return loginService.sendCode(email);
    }

}
